package com.project.imageinterference.exception;

import com.project.imageinterference.vo.ResultCode;

/**
 * ｛BusinessException｝
 *
 * @author cwhao
 * @created 2025/2/6 14:51
 * @lastModified
 * @history
 */
public class BusinessException extends RuntimeException {
    /**
     * code
     */
    private final Integer code;
    /**
     * errorMsg
     */
    private final String errorMsg;

    public BusinessException() {
        code = 500;
        errorMsg = "BusinessException";
    }

    public BusinessException(ResultCode exceptionEnum) {
        super(exceptionEnum.getMessage());
        this.errorMsg = exceptionEnum.getMessage();
        this.code = exceptionEnum.getCode();
    }

    public BusinessException(Integer code, String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
        this.code = code;
    }

    public BusinessException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
        this.code = 500;
    }

    public Integer getCode() {
        return code;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

}
